/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.braveo.dict.javadoc;

import java.util.Collection;
import java.util.Formatter;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

/**
 *
 * @author Yongjie
 */
public class AndroidDict implements List<AndroidWord>{
    public static final String [] DATABASE_CREATION = {
        "CREATE TABLE dict ( _id INTEGER PRIMARY KEY AUTOINCREMENT, Word TEXT NOT NULL, EXPLANATION TEXT NOT NULL )",
        "CREATE INDEX word_index ON dict (Word)",
        "CREATE TABLE android_metadata (locale TEXT)",
        "INSERT INTO android_metadata(locale) VALUES('en_US')"};


    public static final String LINE_INSERT_SQL_TEMPLATE = "INSERT INTO dict(Word, Explanation) VALUES('%s', '%s')";

    private List<AndroidWord> wordList = new LinkedList<AndroidWord>();
    
    public static String createRecordSql(AndroidWord aw){
        //System.out.println("word = " + aw.getWord());
        Formatter f = new Formatter();
        f.format(LINE_INSERT_SQL_TEMPLATE, aw.getWordAsSqlVariable(), aw.getExplainAsSqlVariable());
        return f.toString();
    }

    public void addWord(String word, String explain){
        wordList.add(new AndroidWord(word, explain));
    }

    public <T> T[] toArray(T[] a) {
        return wordList.toArray(a);
    }

    public Object[] toArray() {
        return wordList.toArray();
    }

    public List<AndroidWord> subList(int fromIndex, int toIndex) {
        return wordList.subList(fromIndex, toIndex);
    }

    public int size() {
        return wordList.size();
    }

    public AndroidWord set(int index, AndroidWord element) {
        return wordList.set(index, element);
    }

    public boolean retainAll(Collection<?> c) {
        return wordList.retainAll(c);
    }

    public boolean removeAll(Collection<?> c) {
        return wordList.removeAll(c);
    }

    public AndroidWord remove(int index) {
        return wordList.remove(index);
    }

    public boolean remove(Object o) {
        return wordList.remove(o);
    }

    public ListIterator<AndroidWord> listIterator(int index) {
        return wordList.listIterator(index);
    }

    public ListIterator<AndroidWord> listIterator() {
        return wordList.listIterator();
    }

    public int lastIndexOf(Object o) {
        return wordList.lastIndexOf(o);
    }

    public Iterator<AndroidWord> iterator() {
        return wordList.iterator();
    }

    public boolean isEmpty() {
        return wordList.isEmpty();
    }

    public int indexOf(Object o) {
        return wordList.indexOf(o);
    }

    public AndroidWord get(int index) {
        return wordList.get(index);
    }

    public boolean containsAll(Collection<?> c) {
        return wordList.containsAll(c);
    }

    public boolean contains(Object o) {
        return wordList.contains(o);
    }

    public void clear() {
        wordList.clear();
    }

    public boolean addAll(int index, Collection<? extends AndroidWord> c) {
        return wordList.addAll(index, c);
    }

    public boolean addAll(Collection<? extends AndroidWord> c) {
        return wordList.addAll(c);
    }

    public void add(int index, AndroidWord element) {
        wordList.add(index, element);
    }

    public boolean add(AndroidWord e) {
        return wordList.add(e);
    }

    


}
